#include <iostream>
#include <string>

class Product
{
public:
  virtual ~Product() {}
  
  virtual std::string getName() = 0;
  // ...
};

class ConcreteProductA : public Product
{
public:
  ~ConcreteProductA() {}
  
  std::string getName()
  {
    return "type A";
  }
  // ...
};

class ConcreteProductB : public Product
{
public:
  ~ConcreteProductB() {}
  
  std::string getName()
  {
    return "type B";
  }
  // ...
};

class Creator
{
public:
  virtual ~Creator() {}
  
  virtual Product* createProduct() = 0;
  
  // ...
};

class ConcreteCreatorA : public Creator
{
public:
  ~ConcreteCreatorA() {}
  
  Product* createProduct()
  {
    return new ConcreteProductA();
  }
  // ...
};

class ConcreteCreatorB : public Creator
{
public:
	~ConcreteCreatorB() {}

	Product* createProduct()
	{
		return new ConcreteProductB();
	}
	// ...
};


int main()
{
	Creator *creator = new ConcreteCreatorA();
	Product *p1 = creator->createProduct();
	std::cout << "Product: " << p1->getName() << std::endl;


	creator = new ConcreteCreatorB();
	Product *p2 = creator->createProduct();
	std::cout << "Product: " << p2->getName() << std::endl;

	delete creator;
	creator = nullptr;

	int i;
	std::cin >> i;
	return 0;
}
